//
//  MineTaskDetailController.m
//  Safflower
//
//  Created by 袁亮 on 2017/1/4.
//  Copyright © 2017年 SpaceZ. All rights reserved.
//

#import "MineTaskDetailController.h"
#import "MineTaskDetailView.h"
#import "TaskDataCenter.h"
#import "PhotoBrowerView.h"

@interface MineTaskDetailController ()<MineTaskDetailViewDelegate>

@property (nonatomic, strong) MineTaskDetailView *detailView;
@property (nonatomic, strong) TaskDataCenter *dataCenter;

@end

@implementation MineTaskDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.baseTitle = @"任务详情";
    self.rightBtnTitle = @"返回";
    
    _dataCenter = [TaskDataCenter new];
    
    [self makeMineTaskDetailView];
    [self loadMineTaskDetailData];
}

- (void)makeMineTaskDetailView
{
    _detailView = [[MineTaskDetailView alloc] init];
    _detailView.delegate = self;
    [self.baseView addSubview:_detailView];
    [_detailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(30);
        make.right.mas_equalTo(-30);
        make.bottom.mas_equalTo(-44);
    }];
}

- (void)loadMineTaskDetailData
{
    
    [YJProgressHud showLoadingHud:@"正在加载..."];
    [_dataCenter fetchTaskDetail:self.taskModel complation:^(id data, NSString *error) {
        
        if (error == nil) {
            [YJProgressHud dissmiss];
            _detailView.signData = data;
            [_detailView loadTaskInfo:self.taskModel];
        }else{
            [YJProgressHud showErrorHud:error];
        }

    }];
}

- (void)didSelectSignModel:(SignModel *)signModel
{
    if (signModel.issign == YES) {
        [[PhotoBrowerView sharedBrower] showBrower:signModel];
    }else{
        [YJProgressHud showErrorHud:@"这天没有签到过哦~~~"];
    }
}

- (void)clickRightButton
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
